package com.adapter.objectAdapter;

//这里聚合了被适配对象，而不是继承，   实现适配接口
public class VoltageAdapter implements Voltage5V{

    private Voltage220V voltage220V;

    public VoltageAdapter(Voltage220V voltage220V) {
        this.voltage220V = voltage220V;
    }

    @Override
    public int output5v() {
        //得到原始的220v
        int v200 = voltage220V.output220V();
        System.out.println("原始电压："+v200+"V");
        //开始转换
        int v5 = v200 / 44 ;
        System.out.println("转换后电压"+v5+"V");
        return v5;
    }
}
